#include <bits/stdc++.h>
using namespace std;

class FenwickTree {
public:
    FenwickTree(int size) : size(size) {
        tree.resize(size + 1, 0);
    }

    void add(int index, long long value) {
        for (++index; index <= size; index += index & -index) {
            tree[index] += value;
        }
    }

    long long sum(int index) {
        long long result = 0;
        for (++index; index > 0; index -= index & -index) {
            result += tree[index];
        }
        return result;
    }

private:
    vector<long long> tree;
    int size;
};

int main() {
    int n;
    cin >> n; // 读取点的数量
    vector<pair<int, int>> points(n); // 存储点的坐标和权值

    for (int i = 0; i < n; i++) {
        cin >> points[i].first >> points[i].second; // 读取坐标和权值
    }

    // 按坐标升序排序
    sort(points.begin(), points.end());

    long long totalEffect = 0; // 存储作用效应之和
    FenwickTree fenwick(100000); // 假设坐标范围在 [1, 100000]

    // 从左到右计算作用效应
    for (int i = 0; i < n; i++) {
        int x = points[i].first;
        int w = points[i].second;

        // 计算当前点的作用效应
        // 作用效应 = w[i] * (sum of weights of points to the right)
        totalEffect += w * (fenwick.sum(100000) - fenwick.sum(x)); // 计算右侧所有点的权值和
        fenwick.add(x, w); // 更新树状数组
    }

    cout << totalEffect << endl; // 输出作用效应之和
    return 0;
}